package com.leyou.search.web;

import com.leyou.search.service.IndexSearchService;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("goods")
public class SearchController {

    private  IndexSearchService indexSearchService;

    public SearchController(IndexSearchService indexSearchService) {
        this.indexSearchService = indexSearchService;
    }

    /**
     * 初始化索引库
     */
    @GetMapping("initialization")
    public ResponseEntity<String> init() {
        indexSearchService.createIndexAndMapping();
        indexSearchService.loadData();
        return ResponseEntity.ok("导入成功");
    }
}